package com.ssm.modules.service.impl;


import com.ssm.modules.dao.IUserDao;
import com.ssm.modules.entity.User;
import com.ssm.modules.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("userService")
public class UserServiceImpl implements IUserService {

    @Autowired
    private IUserDao userDao;

    public List<User> findAllUser(int page, int pageSize) {
        if(page > 0) {
            page = (page - 1) * pageSize;
        }
        return userDao.findAllUser(page, pageSize);
    }

    public List<User> findAllTea() {
        return userDao.findAllTea();
    }

    public int findAllUserCount() {
        return userDao.findAllUserCount();
    }

    public User findByUserName(String userName) {
        return userDao.findByUserName(userName);
    }

    public int addUser(User user){
        return userDao.addUser(user);
    }

    public int updateUser(User user) {
        return userDao.updateUser(user);
    }

    public int deleteUser(int id) {
        return userDao.deleteUser(id);
    }

    public int deleteGrade(int stuId) {
        return userDao.deleteGrade(stuId);
    }

    public int addGrade(int stuId, int gradeId) {
        return userDao.addGrade(stuId, gradeId);
    }

    public int addRole(int userId, int roleId) {
        return userDao.addRole(userId, roleId);
    }

}